#!/usr/bin/python
#-*-<coding=UTF-8>-*-

"""
Dictionary operate example.
"""

dict = {"server":"mpilgrim","database":"master"}

print "---------------------------------"
print "display dictionary element"
print "server:%s" 	%dict["server"]
print "database:%s" 	%dict["database"]
print "\n"

print "---------------------------------"
print "add key:value to a dictionary"
print "old dictionary is:%s" %dict
dict["uid"]="sa"
print "new dictionary is:%s" %dict
print "\n"

print "---------------------------------"
print "add same key to dict will over write prev value"
print "old dictionary is:%s" %dict
dict["uid"]="peng.wu"
print "new dictionary is:%s" %dict
print "\n"

print "---------------------------------"
print "dictionary can be add various data type"
dict[3]=4
dict["string"]=3
dict[5]="string"
print dict
print "\n"

print "---------------------------------"
print "del element from a dict"
print "old dictionary is :%s" %dict
del dict[3]
del dict["string"]
print "new dictionary is:%s" %dict
print "\n"



if __name__ == "__main__":
    pass

